<?php
//订单
class searchMod extends base {

	//订单首页
	public function index() {
		$client = get_curl('CITY_GET');
		
		//获取所有城市
		if ($client['status'] != 1) {
			//$this -> error(lang::get($client['status']));
		} else {
			$time = time();
			$start = date('Y-m-d',$time);
			$end = date('Y-m-d',$time+3600*24);
			
			$this -> assign('city', $client['Msg']);
			$this->assign('start',$start);
			$this->assign('end',$end);
			$this -> display();
		}

	}

	//酒店列表
	public function hotel() {
		$CityId = $_GET['CityId'];//城市id
		$ArrivalDate = $_GET['ArrivalDate'];//抵店日期
		$DepartureDate = $_GET['DepartureDate'];//离店日期
		
		$data = array('CityId' => $CityId);
		$data['StartIdx']=1;
		$data['PageSize']=20;
		$client = post_curl($data, 'ORG_BY_CITY');//获取分店
		
		if ($client['status'] != 1) {
			$this -> error(lang::get($client['status']));
		} else {
			$hotel = $client['Msg'];
			if($hotel)
			foreach($hotel as $key=>$val){
				//获取预订房类信息
				$data = array(
				'CardNo'=>$this->_G['member']['CardNo'],
				'CityId'=>$CityId,
				'OrgId'=>$val['OrgId'],
				);
				
				$ArrivalDate && $data['ArrivalDate']=$ArrivalDate;
				$DepartureDate && $data['DepartureDate']=$DepartureDate;
				
				$client = post_curl($data, 'ORG_INFO_GET');//获取预订房类信息
			
				if ($client['status'] != 1) {
					$this -> error(lang::get($client['status']));
				} else {
					$hotel[$key]['fanglei'] = $client['Msg'];
					
				}
				//获取分店服务设施接口
				$sheshi = array(
				'ffbf05d1-a0ab-47c3-aba6-fa896d48e81e'=>'icons2_wifi',//无线网络
				'84fb590e-ebbf-4f12-8e26-c1cb11a6473e'=>'icons2_park',//停车场
				'1e4af52d-69d9-4ae1-b99c-def89add5729'=>'icons2_breakfirst',//餐厅
				'e05dda68-2207-42a9-8649-e4c19e69a74f'=>'icons2_tv',//有线电视
//				'icons2_wifi'=>'ffbf05d1-a0ab-47c3-aba6-fa896d48e81e',//无线网络
//				'icons2_park'=>'84fb590e-ebbf-4f12-8e26-c1cb11a6473e',//停车场
//				'icons2_breakfirst'=>'1e4af52d-69d9-4ae1-b99c-def89add5729',//餐厅
//				'icons2_tv'=>'e05dda68-2207-42a9-8649-e4c19e69a74f',//有线电视
				);
				$data = array(
				'OrgId'=>$val['OrgId'],
				);
				$client = post_curl($data,'SERVICE_GET');
				if ($client['status'] != 1) {
					$this -> error(lang::get($client['status']));
				} else {
					$hotel[$key]['sheshi'] = $client['Msg'];	
				}
				//获取分店图片
				$data = array(
				'OrgId'=>$val['OrgId'],
				);
				$client = post_curl($data,'PICTURE_GET');
				if ($client['status'] != 1) {
					$this -> error(lang::get($client['status']));
				} else {
					$hotel[$key]['pic'] = $client['Msg'][0]['PictureAddress'];					
				}
				
				
			}
			//城市列表
			$client = get_curl('CITY_GET');
			
			$this -> assign('city', $client['Msg']);
			$this -> assign('days', $days);
			$this -> assign('hotel', $hotel);
			$this -> assign('sheshi', $sheshi);
			$this -> display();
		}
	}

	public function resver() {
		if(!$this->_G['member']['CardNo']) $this->error('您还没有登录',url('login/index'));
		
		//住宿天数
		$startdate=strtotime($_POST['ArrivalDate']);
		$enddate=strtotime($_POST['DepartureDate']);
		$days=round(($enddate-$startdate)/3600/24) ;
		$days = $days>0 ? $days : 1;//最小是1
		//最大房间数
		$data = array(
		'CardNo'=>$this->_G['member']['CardNo'],
		'OrgId'=>$_POST['OrgId'],
		'RoomTypeId'=>$_POST['RoomTypeId']
		);		
		$client = post_curl($data,'GET_MAXQTY');
		if ($client['status'] != 1) {
			$this -> error(lang::get($client['status']));
		} else {
			$max = $client['Msg'][0]['Qty'];			
		}
		$this->assign('days',$days);
		$this->assign($_POST);
		$this->assign('max',$max);
		$this -> display();
	}

}
?>